/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.ibrae.mchs.radiation.entities;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author murr
 */
@Entity
@Table(name = "rajon_old", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"ID_RAJON_O"})})
@NamedQueries({
    @NamedQuery(name = "RajonOld.findAll", query = "SELECT r FROM RajonOld r"),
    @NamedQuery(name = "RajonOld.findByIdRajonO", query = "SELECT r FROM RajonOld r WHERE r.idRajonO = :idRajonO"),
    @NamedQuery(name = "RajonOld.findByPlacename", query = "SELECT r FROM RajonOld r WHERE r.placename = :placename")})
public class RajonOld implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_RAJON_O", nullable = false)
    private Integer idRajonO;
    @Basic(optional = false)
    @Column(name = "PLACENAME", nullable = false, length = 50)
    private String placename;
    @OneToMany(mappedBy = "rajonOld")
    private Set<Result> resultSet;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rajonOld")
    private Set<Selsovet> selsovetSet;
    @JoinColumn(name = "ID_SUBJECT", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private SubjectRf subjectRf;
    @OneToMany(mappedBy = "rajonOld")
    private Set<Geoobject> geoobjectSet;

    public RajonOld() {
    }

    public RajonOld(Integer idRajonO) {
        this.idRajonO = idRajonO;
    }

    public RajonOld(Integer idRajonO, String placename) {
        this.idRajonO = idRajonO;
        this.placename = placename;
    }

    public Integer getIdRajonO() {
        return idRajonO;
    }

    public void setIdRajonO(Integer idRajonO) {
        this.idRajonO = idRajonO;
    }

    public String getPlacename() {
        return placename;
    }

    public void setPlacename(String placename) {
        this.placename = placename;
    }

    public Set<Result> getResultSet() {
        return resultSet;
    }

    public void setResultSet(Set<Result> resultSet) {
        this.resultSet = resultSet;
    }

    public Set<Selsovet> getSelsovetSet() {
        return selsovetSet;
    }

    public void setSelsovetSet(Set<Selsovet> selsovetSet) {
        this.selsovetSet = selsovetSet;
    }

    public SubjectRf getSubjectRf() {
        return subjectRf;
    }

    public void setSubjectRf(SubjectRf subjectRf) {
        this.subjectRf = subjectRf;
    }

    public Set<Geoobject> getGeoobjectSet() {
        return geoobjectSet;
    }

    public void setGeoobjectSet(Set<Geoobject> geoobjectSet) {
        this.geoobjectSet = geoobjectSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRajonO != null ? idRajonO.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RajonOld)) {
            return false;
        }
        RajonOld other = (RajonOld) object;
        if ((this.idRajonO == null && other.idRajonO != null) || (this.idRajonO != null && !this.idRajonO.equals(other.idRajonO))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "JPAtest.entities.RajonOld[idRajonO=" + idRajonO + "]";
    }

}
